package com.example.exceldemo.controller;

import com.example.exceldemo.model.ExcelDateVO;
import com.example.exceldemo.service.ExportExcelService;
import com.example.exceldemo.utils.ExcelTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@RestController
public class ExcelTestCotroller {

    @Autowired
    ExportExcelService exportExcelService;

    /**
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping(value = "/exportExcel")
    public void exportCirExcel(HttpServletRequest request, HttpServletResponse response) {

        List<ExcelDateVO> resultList = new ArrayList<>();
        ExcelDateVO datavo = new ExcelDateVO();
        datavo.setName("yszc");
        datavo.setAge(12);
        resultList.add(datavo);

        exportExcelService.exportExcel(request, response, resultList,new ExcelTemplate("cir"));
    }
}
